package cn.wendellup.bootStrap.valueobject.entity;

import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

import org.springframework.jdbc.core.RowMapper;

public class AdvDetail implements Serializable, RowMapper<AdvDetail> {
    private static final long serialVersionUID = 1L;

    public static class FieldStatus {
        public static int positionTypeId = 1 << 0;
        public static int advType = 1 << 1;
        public static int recordType = 1 << 2;
        public static int efsId = 1 << 3;
        public static int operationId = 1 << 4;
        public static int operationName = 1 << 5;
        public static int linkUrl = 1 << 6;
        public static int status = 1 << 7;
        public static int sortNo = 1 << 8;
        public static int description = 1 << 9;
        public static int beginTime = 1 << 10;
        public static int endTime = 1 << 11;
        public static int updateTime = 1 << 12;
        public static int title = 1 << 13;
    }

    private int id;
    private int positionTypeId;
    private int advType;
    private int recordType;
    private int efsId;
    private int operationId;
    private String operationName = "";
    private String linkUrl = "";
    private int status;
    private int sortNo;
    private String description = "";
    private Date beginTime;
    private Date endTime;
    private Date insertTime;
    private Date updateTime;
    private String title = "";
//    private String img_url = "";
//    private String beginString = "";
//    private String endString = "";

    private int updateStatus = 0;

    public int getUpdateStatus() {
        return updateStatus;
    }

    public void setUpdateStatus(int updateStatus) {
        this.updateStatus = updateStatus;
    }

    
    public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getPositionTypeId() {
        return positionTypeId;
    }

    public void setPositionTypeId(int positionTypeId) {
        if (this.positionTypeId != positionTypeId) {
            this.positionTypeId = positionTypeId;
            this.updateStatus = this.updateStatus | AdvDetail.FieldStatus.positionTypeId;
        }
    }

    public int getAdvType() {
        return advType;
    }

    public void setAdvType(int advType) {
        if (this.advType != advType) {
            this.advType = advType;
            this.updateStatus = this.updateStatus | AdvDetail.FieldStatus.advType;
        }
    }

    public int getRecordType() {
        return recordType;
    }

    public void setRecordType(int recordType) {
        if (this.recordType != recordType) {
            this.recordType = recordType;
            this.updateStatus = this.updateStatus | AdvDetail.FieldStatus.recordType;
        }
    }

    public int getEfsId() {
        return efsId;
    }

    public void setEfsId(int efsId) {
        if (this.efsId != efsId) {
            this.efsId = efsId;
            this.updateStatus = this.updateStatus | AdvDetail.FieldStatus.efsId;
        }
    }

    public int getOperationId() {
        return operationId;
    }

    public void setOperationId(int operationId) {
        if (this.operationId != operationId) {
            this.operationId = operationId;
            this.updateStatus = this.updateStatus | AdvDetail.FieldStatus.operationId;
        }
    }

    public String getOperationName() {
        return operationName;
    }

    public void setOperationName(String operationName) {
        if (this.operationName != operationName) {
            this.operationName = operationName;
            this.updateStatus = this.updateStatus | AdvDetail.FieldStatus.operationName;
        }
    }

    public String getLinkUrl() {
        return linkUrl;
    }

    public void setLinkUrl(String linkUrl) {
        if (this.linkUrl != linkUrl) {
            this.linkUrl = linkUrl;
            this.updateStatus = this.updateStatus | AdvDetail.FieldStatus.linkUrl;
        }
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        if (this.status != status) {
            this.status = status;
            this.updateStatus = this.updateStatus | AdvDetail.FieldStatus.status;
        }
    }

    public int getSortNo() {
        return sortNo;
    }

    public void setSortNo(int sortNo) {
        if (this.sortNo != sortNo) {
            this.sortNo = sortNo;
            this.updateStatus = this.updateStatus | AdvDetail.FieldStatus.sortNo;
        }
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        if (this.description != description) {
            this.description = description;
            this.updateStatus = this.updateStatus | AdvDetail.FieldStatus.description;
        }
    }

    public Date getBeginTime() {
        return beginTime;
    }

    public void setBeginTime(Date beginTime) {
        if (this.beginTime != beginTime) {
            this.beginTime = beginTime;
            this.updateStatus = this.updateStatus | AdvDetail.FieldStatus.beginTime;
        }
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        if (this.endTime != endTime) {
            this.endTime = endTime;
            this.updateStatus = this.updateStatus | AdvDetail.FieldStatus.endTime;
        }
    }

    public Date getInsertTime() {
        return insertTime;
    }

    public void setInsertTime(Date insertTime) {
        this.insertTime = insertTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        if (this.updateTime != updateTime) {
            this.updateTime = updateTime;
            this.updateStatus = this.updateStatus | AdvDetail.FieldStatus.updateTime;
        }
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        if (this.title != title) {
            this.title = title;
            this.updateStatus = this.updateStatus | AdvDetail.FieldStatus.title;
        }
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("AdvDetail [id=");
        builder.append(id);
        builder.append(", title=");
        builder.append(title);
        builder.append(", positionTypeId=");
        builder.append(positionTypeId);
        builder.append(", advType=");
        builder.append(advType);
        builder.append(", recordType=");
        builder.append(recordType);
        builder.append(", efsId=");
        builder.append(efsId);
        builder.append(", operationId=");
        builder.append(operationId);
        builder.append(", operationName=");
        builder.append(operationName);
        builder.append(", linkUrl=");
        builder.append(linkUrl);
        builder.append(", img_url=");
        builder.append(", status=");
        builder.append(status);
        builder.append(", sortNo=");
        builder.append(sortNo);
        builder.append(", description=");
        builder.append(description);
        builder.append(", beginTime=");
        builder.append(beginTime);
        builder.append(", endTime=");
        builder.append(endTime);
        builder.append(", insertTime=");
        builder.append(insertTime);
        builder.append(", updateTime=");
        builder.append(updateTime);
        builder.append(", updateStatus=");
        builder.append(updateStatus);
        builder.append("]");
        return builder.toString();
    }

	@Override
	public AdvDetail mapRow(ResultSet rs, int arg1) throws SQLException {
		AdvDetail advDetail = new AdvDetail();
		advDetail.setId(rs.getInt("id"));
		advDetail.setPositionTypeId(rs.getInt("position_id"));
		advDetail.setAdvType(rs.getInt("ad_type"));
		advDetail.setRecordType(rs.getInt("record_type"));
		advDetail.setEfsId(rs.getInt("efs_id"));
		advDetail.setOperationId(rs.getInt("operator_id"));
		advDetail.setOperationName(rs.getString("operation_name"));
		advDetail.setLinkUrl(rs.getString("link_url"));
		advDetail.setStatus(rs.getInt("status"));
		advDetail.setSortNo(rs.getInt("sort_no"));
		advDetail.setDescription(rs.getString("description"));
		advDetail.setBeginTime(rs.getDate("begin_time"));
		advDetail.setEndTime(rs.getDate("end_time"));
		advDetail.setInsertTime(rs.getDate("insert_time"));
		advDetail.setUpdateTime(rs.getDate("update_time"));
		advDetail.setTitle(rs.getString("title"));
		return advDetail;
	}

}
